package gameAppLayer;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.RandomStringUtils;

import stars.enums.StarColors;
import stars.enums.StarDistributions;
import stars.enums.StarParameters;
import stars.enums.StarSystemDistributions;
import stars.enums.StarSystemNames;
import stars.enums.StarSystemParameters;
import stars.enums.StarTypeData;
import view.EViewList;

import com.thoughtworks.xstream.XStream;

import galaxies.CustomGalaxyData;
import galaxies.enums.EarthLike;
import galaxies.enums.GalaxyDensity;
import galaxies.enums.GalaxySize;
import galaxies.enums.ResearchRate;
import galaxies.enums.SpiralArmNumbers;
import gameAppLayer.enums.Constants;

/*
 * Creates all relevant XML game files from scratch, using default values.  Not called from
 * the game itself.  These XML files and their values are used by the game in various locations
 */
public class XMLFileBuilder {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws ClassNotFoundException 
	 */
	public static void main(String[] args) throws IOException, ClassNotFoundException {
		XMLFileBuilder fb = new XMLFileBuilder();
		fb.buildXMLFiles();
	}
	/*
	 * TODO:  Decide whether or not to use STAX or XStream here.  STAX is more conventional and will
	 * be used to read in the data anyway...
	 * 
	 */
	public void buildXMLFiles() throws IOException, ClassNotFoundException {
		XStream xstream = new XStream();
		
		//These aliases must be present in the XMLLoader class as well!!
		xstream.alias("galaxySize", GalaxySize.class);
		xstream.alias("earthLike", EarthLike.class);
		xstream.alias("galaxyDensity", GalaxyDensity.class);
		xstream.alias("researchRate", ResearchRate.class);
		xstream.alias("spiralArmNumbers", SpiralArmNumbers.class);
		xstream.alias("starSystemParameters", StarSystemParameters.class);
		xstream.alias("starColors", StarColors.class);
		xstream.alias("starDistributions", StarDistributions.class);
		xstream.alias("starParameters", StarParameters.class);
		xstream.alias("starTypeData", StarTypeData.class);
		xstream.alias("starSystemDistributions", StarSystemDistributions.class);
		xstream.alias("starSystemNames", StarSystemNames.class);
		xstream.alias("customGalaxy", CustomGalaxyData.class);
		//Continue...
		
		
		//----------------------------------------------
		//Build GalaxySize file		
		GalaxySize gs = new GalaxySize();		
		gs.addGalaxySize("TINY_MIN", 210);
		gs.addGalaxySize("TINY_MAX", 630);
		gs.addGalaxySize("TINY_DEF", -1);
		
		gs.addGalaxySize("SMALL_MIN", 1050);
		gs.addGalaxySize("SMALL_MAX", 2100);
		gs.addGalaxySize("SMALL_DEF", -1);
		
		gs.addGalaxySize("MEDIUM_MIN", 5250);
		gs.addGalaxySize("MEDIUM_MAX", 10500);
		gs.addGalaxySize("MEDIUM_DEF", -1);
		
		gs.addGalaxySize("LARGE_MIN", 15750);
		gs.addGalaxySize("LARGE_MAX", 31500);
		gs.addGalaxySize("LARGE_DEF", -1);
		
		gs.addGalaxySize("HUGE_MIN", 42000);
		gs.addGalaxySize("HUGE_MAX", 84000);
		gs.addGalaxySize("HUGE_DEF", -1);
		
		gs.addGalaxySize("MAX", 150000);
		
		File file = new File(Constants.dataPath + "//GalaxySize.xml");		
		FileOutputStream fos = new FileOutputStream(file);
		OutputStreamWriter osw = new OutputStreamWriter(fos);
		ObjectOutputStream out = xstream.createObjectOutputStream(osw);		
		out.writeObject(gs);
		out.close();
		//----------------------------------------------
		
		//----------------------------------------------
		//Build EarthLike file
		EarthLike el = new EarthLike();
		el.addEarthLikeProb("PLENTIFUL", 0.15);
		el.addEarthLikeProb("COMMON", 0.05);
		el.addEarthLikeProb("UNCOMMON", 0.01);
		el.addEarthLikeProb("RARE", 0.001);
		el.addEarthLikeProb("VERY_RARE", 0.0001);
		el.addEarthLikeProb("UNIQUE", 0.0);
		
		file = new File(Constants.dataPath + "//EarthLike.xml");
		fos = new FileOutputStream(file);
		osw = new OutputStreamWriter(fos);
		out = xstream.createObjectOutputStream(osw);		
		out.writeObject(el);
		out.close();
		//----------------------------------------------
		
		
		//----------------------------------------------
		//Build GalaxyDensity file
		GalaxyDensity gd = new GalaxyDensity();
		
		gd.addDensity("SPARSE", 80);
		gd.addDensity("LOW", 60);
		gd.addDensity("MODERATE", 40);
		gd.addDensity("HIGH", 20);
		gd.addDensity("PACKED", 10);
		
		file = new File(Constants.dataPath + "//GalaxyDensity.xml");
		fos = new FileOutputStream(file);
		osw = new OutputStreamWriter(fos);
		out = xstream.createObjectOutputStream(osw);		
		out.writeObject(gd);
		out.close();		
		//----------------------------------------------
		
		
		//----------------------------------------------
		//Build ResearchRate file
		ResearchRate rr = new ResearchRate();
		
		rr.addResearchRate("VERY_SLOW", 0.1);
		rr.addResearchRate("SLOW", 0.5);
		rr.addResearchRate("AVERAGE", 1.0);
		rr.addResearchRate("FAST", 2.0);
		rr.addResearchRate("VERY_FAST", 10.0);
		
		file = new File(Constants.dataPath + "//ResearchRate.xml");
		fos = new FileOutputStream(file);
		osw = new OutputStreamWriter(fos);
		out = xstream.createObjectOutputStream(osw);		
		out.writeObject(rr);
		out.close();
		//----------------------------------------------
		
		
		//----------------------------------------------
		//Build SpiralArmNumbers file
		SpiralArmNumbers san = new SpiralArmNumbers();
		
		san.addSpiralArmNumber("2", 10);
		san.addSpiralArmNumber("3", 5249);
		san.addSpiralArmNumber("4", 15749);
		san.addSpiralArmNumber("6", 41999);
		
		file = new File(Constants.dataPath + "//SpiralArmNumbers.xml");
		fos = new FileOutputStream(file);
		osw = new OutputStreamWriter(fos);
		out = xstream.createObjectOutputStream(osw);		
		out.writeObject(san);
		out.close();
		//----------------------------------------------
		
		
		//----------------------------------------------
		//Build star system params file
		StarSystemParameters ssp = new StarSystemParameters();
		
		ssp.addParameter("MIN_HABITABLE_ORBIT_AU", 0.05);
		ssp.addParameter("MAX_HABITABLE_ORBIT_AU", 100);
		ssp.addParameter("MIN_BINARY_STAR_SEPARATION_AU", 3);
		ssp.addParameter("MAX_BINARY_STAR_SEPARATION_AU", 150);
		ssp.addParameter("MIN_BINARY_STAR_DEADZONE_AU", 3);
		ssp.addParameter("MAX_BINARY_STAR_DEADZONE_AU", 30);
		
		ssp.addParameter("MAX_ORBITS_PER_SYSTEM", 20);
		ssp.addParameter("MIN_ORBITS_PER_SYSTEM", 0);
		//ssp.addParameter("AVERAGE_ORBITS_PER_SYSTEM", 10);
		//ssp.addParameter("VARIANCE_ORBITS_PER_SYSTEM", 5);
		//Continue...
		
		
		file = new File(Constants.dataPath + "//StarSystemParameters.xml");
		fos = new FileOutputStream(file);
		osw = new OutputStreamWriter(fos);
		out = xstream.createObjectOutputStream(osw);		
		out.writeObject(ssp);
		out.close();		
		//----------------------------------------------
		
		
		//----------------------------------------------
		//Build star colors file
		StarColors sc = new StarColors();
		
		ArrayList<Integer> colors;
		
		colors = new ArrayList<Integer>();
		colors.add(100); colors.add(149); colors.add(237);
		sc.addColor("BLUE", colors);
		
		colors = new ArrayList<Integer>();
		colors.add(176); colors.add(226); colors.add(255);
		sc.addColor("BLUEWHITE", colors);
		
		colors = new ArrayList<Integer>();
		colors.add(255); colors.add(255); colors.add(240);
		sc.addColor("WHITE", colors);
		
		colors = new ArrayList<Integer>();
		colors.add(255); colors.add(250); colors.add(205);
		sc.addColor("YELLOWWHITE", colors);
		
		colors = new ArrayList<Integer>();
		colors.add(255); colors.add(255); colors.add(0);
		sc.addColor("YELLOW", colors);
		
		colors = new ArrayList<Integer>();
		colors.add(255); colors.add(165); colors.add(0);
		sc.addColor("ORANGE", colors);
		
		colors = new ArrayList<Integer>();
		colors.add(255); colors.add(0); colors.add(0);
		sc.addColor("RED", colors);
		
		colors = new ArrayList<Integer>();
		colors.add(205); colors.add(0); colors.add(205);
		sc.addColor("MAGENTA", colors);
		
		colors = new ArrayList<Integer>();
		colors.add(0); colors.add(0); colors.add(0);
		sc.addColor("BLACK", colors);
		
		file = new File(Constants.dataPath + "//StarColors.xml");
		fos = new FileOutputStream(file);
		osw = new OutputStreamWriter(fos);
		out = xstream.createObjectOutputStream(osw);		
		out.writeObject(sc);
		out.close();
		//----------------------------------------------
		
		
		//----------------------------------------------
		//Build star distribution file
		StarDistributions sd = new StarDistributions();
		
		HashMap<String, Double> youngDist = new HashMap<String, Double>();
		HashMap<String, Double> avgDist = new HashMap<String, Double>();
		HashMap<String, Double> oldDist = new HashMap<String, Double>();
		
		youngDist.put("WHITEDWARF", 0.01);
		avgDist.put("WHITEDWARF", 0.02);
		oldDist.put("WHITEDWARF", 0.04);
		
		youngDist.put("MSBLUE", 0.00001);
		avgDist.put("MSBLUE", 0.00001);
		oldDist.put("MSBLUE", 0.0);
		
		youngDist.put("MSBLUEWHITE", 0.045);
		avgDist.put("MSBLUEWHITE", 0.001125);
		oldDist.put("MSBLUEWHITE", 0.001125);
		
		youngDist.put("MSWHITE", 0.04499);
		avgDist.put("MSWHITE", 0.023615);
		oldDist.put("MSWHITE", 0.005625);
		
		youngDist.put("MSYELLOWWHITE", 0.126);
		avgDist.put("MSYELLOWWHITE", 0.063);
		oldDist.put("MSYELLOWWHITE", 0.027);
		
		youngDist.put("MSYELLOW", 0.198);
		avgDist.put("MSYELLOW", 0.15975);
		oldDist.put("MSYELLOW", 0.06975);
		
		youngDist.put("MSORANGE", 0.243);
		avgDist.put("MSORANGE", 0.2115);
		oldDist.put("MSORANGE", 0.1125);
		
		youngDist.put("MSRED", 0.243);
		avgDist.put("MSRED", 0.441);
		oldDist.put("MSRED", 0.684);
		
		youngDist.put("GIANT", 0.06);
		avgDist.put("GIANT", 0.05);
		oldDist.put("GIANT", 0.009);
		
		youngDist.put("SUPERGIANT", 0.01);
		avgDist.put("SUPERGIANT", 0.009);
		oldDist.put("SUPERGIANT", 0.0005);
		
		youngDist.put("HYPERGIANT", 0.01);
		avgDist.put("HYPERGIANT", 0.001);
		oldDist.put("HYPERGIANT", 0.0005);
		
		youngDist.put("NEUTRON", 0.005);
		avgDist.put("NEUTRON", 0.01);
		oldDist.put("NEUTRON", 0.025);
		
		youngDist.put("BLACKHOLE", 0.005);
		avgDist.put("BLACKHOLE", 0.01);
		oldDist.put("BLACKHOLE", 0.025);
		
		sd.setProbabilities(youngDist, "young");
		sd.setProbabilities(avgDist, "average");
		sd.setProbabilities(oldDist, "old");
		
		file = new File(Constants.dataPath + "//StarDistributions.xml");
		fos = new FileOutputStream(file);
		osw = new OutputStreamWriter(fos);
		out = xstream.createObjectOutputStream(osw);		
		out.writeObject(sd);
		out.close();
		//----------------------------------------------
		
		
		//----------------------------------------------
		//TODO:  Create starMods.xml file.  Must tie this in with events xml listing too.
		//----------------------------------------------
		
		
		//----------------------------------------------
		//Build StarParameters file
		StarParameters sp = new StarParameters();		
		StarTypeData starData;		
		String name;
		
		name = "WHITEDWARF";
		starData = new StarTypeData(name);
		starData.setMinLuminance(0.0001);
		starData.setMaxLuminance(10);
		starData.setMinTemp(4000);
		starData.setMaxTemp(52000);
		starData.setMinMass(0.05);
		starData.setMaxMass(1.4);
		starData.setMinRadius(0.003);
		starData.setMaxRadius(0.036);
		starData.setMinRotation(0.5);
		starData.setMaxRotation(0.7);
		starData.setMinMagField(0.0);
		starData.setMaxMagField(10);
		starData.setBinaryProb(0.3);
		starData.setTrinaryProb(0.05);
		starData.setQuadProb(0.01);
		sp.addParameter(name, starData);
		
		name = "MSBLUE";
		starData = new StarTypeData(name);
		starData.setMinLuminance(30000.0);
		starData.setMaxLuminance(1000000.0);
		starData.setMinTemp(30000.0);
		starData.setMaxTemp(52000.0);
		starData.setMinMass(19.02);
		starData.setMaxMass(51.8);
		starData.setMinRadius(6.42);
		starData.setMaxRadius(12.36);
		starData.setMinRotation(0.0);
		starData.setMaxRotation(1.5*0.00001);
		starData.setMinMagField(200.0);
		starData.setMaxMagField(10000.0);
		starData.setBinaryProb(0.6);
		starData.setTrinaryProb(0.15);
		starData.setQuadProb(0.05);
		sp.addParameter(name, starData);
		
		name = "MSBLUEWHITE";
		starData = new StarTypeData(name);
		starData.setMinLuminance(16.0);
		starData.setMaxLuminance(30000.0);
		starData.setMinTemp(10000.0);
		starData.setMaxTemp(30000.0);
		starData.setMinMass(2.2);
		starData.setMaxMass(19.01);
		starData.setMinRadius(1.33);
		starData.setMaxRadius(6.43);
		starData.setMinRotation(7.6*0.00001);
		starData.setMaxRotation(11.1*0.00001);
		starData.setMinMagField(200.0);
		starData.setMaxMagField(10000.0);
		starData.setBinaryProb(0.6);
		starData.setTrinaryProb(0.15);
		starData.setQuadProb(0.05);
		sp.addParameter(name, starData);
		
		name = "MSWHITE";
		starData = new StarTypeData(name);
		starData.setMinLuminance(3.0);
		starData.setMaxLuminance(16.0);
		starData.setMinTemp(7600.0);
		starData.setMaxTemp(10000.0);
		starData.setMinMass(1.36);
		starData.setMaxMass(2.2);
		starData.setMinRadius(1.0);
		starData.setMaxRadius(1.33);
		starData.setMinRotation(13.0*0.00001);
		starData.setMaxRotation(18.0*0.00001);
		starData.setMinMagField(200.0);
		starData.setMaxMagField(10000.0);
		starData.setBinaryProb(0.4);
		starData.setTrinaryProb(0.08);
		starData.setQuadProb(0.02);
		sp.addParameter(name, starData);
		
		name = "MSYELLOWWHITE";
		starData = new StarTypeData(name);
		starData.setMinLuminance(1.5);
		starData.setMaxLuminance(5.0);
		starData.setMinTemp(6000.0);
		starData.setMaxTemp(7600.0);
		starData.setMinMass(1.12);
		starData.setMaxMass(1.58);
		starData.setMinRadius(1.13);
		starData.setMaxRadius(1.30);
		starData.setMinRotation(3.0*0.00001);
		starData.setMaxRotation(10.0*0.00001);
		starData.setMinMagField(200.0);
		starData.setMaxMagField(10000.0);
		starData.setBinaryProb(0.4);
		starData.setTrinaryProb(0.08);
		starData.setQuadProb(0.02);
		sp.addParameter(name, starData);
		
		name = "MSYELLOW";
		starData = new StarTypeData(name);
		starData.setMinLuminance(0.5);
		starData.setMaxLuminance(1.5);
		starData.setMinTemp(5200.0);
		starData.setMaxTemp(6000.0);
		starData.setMinMass(0.82);
		starData.setMaxMass(1.12);
		starData.setMinRadius(0.87);
		starData.setMaxRadius(1.13);
		starData.setMinRotation(0.1*0.00001);
		starData.setMaxRotation(3.0*0.00001);
		starData.setMinMagField(200.0);
		starData.setMaxMagField(10000.0);
		starData.setBinaryProb(0.4);
		starData.setTrinaryProb(0.08);
		starData.setQuadProb(0.02);
		sp.addParameter(name, starData);
		
		name = "MSORANGE";
		starData = new StarTypeData(name);
		starData.setMinLuminance(0.09);
		starData.setMaxLuminance(0.5);
		starData.setMinTemp(4000);
		starData.setMaxTemp(5200.0);
		starData.setMinMass(0.5);
		starData.setMaxMass(0.82);
		starData.setMinRadius(0.62);
		starData.setMaxRadius(0.87);
		starData.setMinRotation(0.05*0.00001);
		starData.setMaxRotation(0.1*0.00001);
		starData.setMinMagField(200.0);
		starData.setMaxMagField(10000.0);
		starData.setBinaryProb(0.4);
		starData.setTrinaryProb(0.08);
		starData.setQuadProb(0.02);
		sp.addParameter(name, starData);
		
		name = "MSRED";
		starData = new StarTypeData(name);
		starData.setMinLuminance(0.0002);
		starData.setMaxLuminance(0.09);
		starData.setMinTemp(2000.0);
		starData.setMaxTemp(3900.0);
		starData.setMinMass(0.087);
		starData.setMaxMass(0.5);
		starData.setMinRadius(0.11);
		starData.setMaxRadius(0.66);
		starData.setMinRotation(0.01*0.00001);
		starData.setMaxRotation(0.05*0.00001);
		starData.setMinMagField(200.0);
		starData.setMaxMagField(10000.0);
		starData.setBinaryProb(0.2);
		starData.setTrinaryProb(0.04);
		starData.setQuadProb(0.01);
		sp.addParameter(name, starData);
		
		name = "GIANT";
		starData = new StarTypeData(name);
		starData.setMinLuminance(90.0);
		starData.setMaxLuminance(1000.0);
		starData.setMinTemp(2500.0);
		starData.setMaxTemp(15000.0);
		starData.setMinMass(0.1);
		starData.setMaxMass(4.0);
		starData.setMinRadius(10.0);
		starData.setMaxRadius(100.0);
		starData.setMinRotation(1.0*0.00001);
		starData.setMaxRotation(2.0*0.00001);
		starData.setMinMagField(200.0);
		starData.setMaxMagField(10000.0);
		starData.setBinaryProb(0.6);
		starData.setTrinaryProb(0.15);
		starData.setQuadProb(0.05);
		sp.addParameter(name, starData);
		
		name = "SUPERGIANT";
		starData = new StarTypeData(name);
		starData.setMinLuminance(30000.0);
		starData.setMaxLuminance(200000.0);
		starData.setMinTemp(2500.0);
		starData.setMaxTemp(35000.0);
		starData.setMinMass(10.0);
		starData.setMaxMass(70.1);
		starData.setMinRadius(30.0);
		starData.setMaxRadius(500.0);
		starData.setMinRotation(1.0*0.00001);
		starData.setMaxRotation(2.0*0.00001);
		starData.setMinMagField(200.0);
		starData.setMaxMagField(10000.0);
		starData.setBinaryProb(0.6);
		starData.setTrinaryProb(0.15);
		starData.setQuadProb(0.05);
		sp.addParameter(name, starData);
		
		name = "HYPERGIANT";
		starData = new StarTypeData(name);
		starData.setMinLuminance(200000.0);
		starData.setMaxLuminance(8000000.0);
		starData.setMinTemp(3500.0);
		starData.setMaxTemp(35000.0);
		starData.setMinMass(100.0);
		starData.setMaxMass(265.0);
		starData.setMinRadius(35.0);
		starData.setMaxRadius(2000.0);
		starData.setMinRotation(1.0*0.00001);
		starData.setMaxRotation(2.0*0.00001);
		starData.setMinMagField(200.0);
		starData.setMaxMagField(10000.0);
		starData.setBinaryProb(0.6);
		starData.setTrinaryProb(0.15);
		starData.setQuadProb(0.05);
		sp.addParameter(name, starData);
		
		name = "NEUTRON";
		starData = new StarTypeData(name);
		starData.setMinLuminance(0.000001);
		starData.setMaxLuminance(0.000001);
		starData.setMinTemp(800000.0);
		starData.setMaxTemp(1200000.0);
		starData.setMinMass(1.35);
		starData.setMaxMass(2.0);
		starData.setMinRadius(0.000016);
		starData.setMaxRadius(0.000018);
		starData.setMinRotation(0.0);
		starData.setMaxRotation(6300.0);
		starData.setMinMagField(Math.pow(10, 12));
		starData.setMaxMagField(10000*Math.pow(10,12));
		starData.setBinaryProb(0.05);
		starData.setTrinaryProb(0.01);
		starData.setQuadProb(0.0);
		sp.addParameter(name, starData);
		
		name = "BLACKHOLE";
		starData = new StarTypeData(name);
		starData.setMinLuminance(0.0);
		starData.setMaxLuminance(0.0);
		starData.setMinTemp(0.00001);
		starData.setMaxTemp(0.00001);
		starData.setMinMass(3.8);
		starData.setMaxMass(15.0);
		starData.setMinRadius(0.000016);
		starData.setMaxRadius(0.000063);
		starData.setMinRotation(0.0);
		starData.setMaxRotation(9740.0);
		starData.setMinMagField(Math.pow(10, 12));
		starData.setMaxMagField(10000*Math.pow(10,12));
		starData.setBinaryProb(0.05);
		starData.setTrinaryProb(0.01);
		starData.setQuadProb(0.0);
		sp.addParameter(name, starData);
		
		name = "T_TAURI";
		starData = new StarTypeData(name);
		starData.setMinLuminance(0.0002);
		starData.setMaxLuminance(5.0);
		starData.setMinTemp(2000.0);
		starData.setMaxTemp(7600.0);
		starData.setMinMass(0.087);
		starData.setMaxMass(1.58);
		starData.setMinRadius(0.55);
		starData.setMaxRadius(6.5);
		starData.setMinRotation(0.2*0.00001);
		starData.setMaxRotation(540.0*0.00001);
		starData.setMinMagField(200.0);
		starData.setMaxMagField(10000.0);
		starData.setBinaryProb(0.0);
		starData.setTrinaryProb(0.0);
		starData.setQuadProb(0.0);
		sp.addParameter(name, starData);
		
		file = new File(Constants.dataPath + "//StarParameters.xml");
		fos = new FileOutputStream(file);
		osw = new OutputStreamWriter(fos);
		out = xstream.createObjectOutputStream(osw);		
		out.writeObject(sp);
		out.close();
		//----------------------------------------------
		
		
		//----------------------------------------------
		//StarSystemDistributions
		StarSystemDistributions ssd = new StarSystemDistributions();
		
		ssd.addProbability("1", 0.5);
		ssd.addProbability("2", 0.2);
		ssd.addProbability("11", 0.2);
		ssd.addProbability("3", 0.02);
		ssd.addProbability("12", 0.02);
		ssd.addProbability("21", 0.02);
		ssd.addProbability("111", 0.02);
		ssd.addProbability("4", 0.005);
		ssd.addProbability("31", 0.005);
		ssd.addProbability("22", 0.005);
		ssd.addProbability("211", 0.005);
		
//		ArrayList<Integer> nums = new ArrayList<Integer>();
//		nums.add(1);
//		ssd.addStarGroupParam("1", nums);
//		
//		nums = new ArrayList<Integer>();
//		nums.add(2);
//		ssd.addStarGroupParam("2", nums);
//		
//		nums = new ArrayList<Integer>();
//		nums.add(1); nums.add(1);
//		ssd.addStarGroupParam("11", nums);
//		
//		nums = new ArrayList<Integer>();
//		nums.add(3);
//		ssd.addStarGroupParam("3", nums);
//		
//		nums = new ArrayList<Integer>();
//		nums.add(1); nums.add(2);
//		ssd.addStarGroupParam("12", nums);
//		
//		nums = new ArrayList<Integer>();
//		nums.add(2); nums.add(1);
//		ssd.addStarGroupParam("21", nums);
//		
//		nums = new ArrayList<Integer>();
//		nums.add(1); nums.add(1); nums.add(1);
//		ssd.addStarGroupParam("111", nums);
//		
//		nums = new ArrayList<Integer>();
//		nums.add(4);
//		ssd.addStarGroupParam("4", nums);
//		
//		nums = new ArrayList<Integer>();
//		nums.add(3); nums.add(1);
//		ssd.addStarGroupParam("31", nums);
//		
//		nums = new ArrayList<Integer>();
//		nums.add(2); nums.add(2);
//		ssd.addStarGroupParam("22", nums);
//		
//		nums = new ArrayList<Integer>();
//		nums.add(2); nums.add(1); nums.add(1);
//		ssd.addStarGroupParam("211", nums);
		
		
		file = new File(Constants.dataPath + "//StarSystemDistributions.xml");
		fos = new FileOutputStream(file);
		osw = new OutputStreamWriter(fos);
		out = xstream.createObjectOutputStream(osw);		
		out.writeObject(ssd);
		out.close();
		//----------------------------------------------
		
		
		//----------------------------------------------
		//Generate temporary starSystem names file
		StarSystemNames ssn = new StarSystemNames();
		
		ArrayList<String> stringList = new ArrayList<String>();
		for (int i = 0; i < 1000; i++) {
			stringList.add(RandomStringUtils.randomAlphanumeric(5));
		}
		
		ssn.setEntries(stringList);
		
		file = new File(Constants.dataPath + "//SystemNames.xml");
		fos = new FileOutputStream(file);
		osw = new OutputStreamWriter(fos);
		out = xstream.createObjectOutputStream(osw);		
		out.writeObject(ssn);
		out.close();
		//----------------------------------------------
				
		
		//----------------------------------------------
		//Generate temporary custom galaxy file
		CustomGalaxyData cgd = new CustomGalaxyData();
		ArrayList<Double> point = new ArrayList<Double>();
		point.add(1.0); point.add(1.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(-1.0); point.add(1.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(-1.0); point.add(-1.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(1.0); point.add(1.0);
		cgd.addPoint(point);
		
		cgd.setName("Box");
		
		file = new File(Constants.dataPath + "//CustomGalaxies//BoxGalaxy.xml");
		fos = new FileOutputStream(file);
		osw = new OutputStreamWriter(fos);
		out = xstream.createObjectOutputStream(osw);		
		out.writeObject(cgd);
		out.close();
		
		//Second galaxy file
		
		cgd = new CustomGalaxyData();
		point = new ArrayList<Double>();
		point.add(2.0); point.add(1.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(-1.0); point.add(1.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(-1.0); point.add(-1.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(1.0); point.add(1.0);
		cgd.addPoint(point);
		
		cgd.setName("Box2");
		
		file = new File(Constants.dataPath + "//CustomGalaxies//BoxGalaxy2.xml");
		fos = new FileOutputStream(file);
		osw = new OutputStreamWriter(fos);
		out = xstream.createObjectOutputStream(osw);		
		out.writeObject(cgd);
		out.close();
		
		//Third galaxy file
		//eye 1
		cgd = new CustomGalaxyData();
		point = new ArrayList<Double>();
		point.add(2.0); point.add(2.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(3.0); point.add(3.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(2.0); point.add(4.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(1.0); point.add(3.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(2.0); point.add(2.0);
		cgd.addPoint(point);
		
		//start mouth
		point = new ArrayList<Double>();
		point.add(3.0); point.add(1.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(2.0); point.add(-1.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(0.0); point.add(-1.5);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(-2.0); point.add(-1.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(-3.0); point.add(1.0);
		cgd.addPoint(point);
		
		//start eye 2
		point = new ArrayList<Double>();
		point.add(-2.0); point.add(2.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(-3.0); point.add(3.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(-2.0); point.add(4.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(-1.0); point.add(3.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(-2.0); point.add(2.0);
		cgd.addPoint(point);
		
		//back to mouth
		point = new ArrayList<Double>();
		point.add(-3.0); point.add(1.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(0.0); point.add(1.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(3.0); point.add(1.0);
		cgd.addPoint(point);
		
		point = new ArrayList<Double>();
		point.add(2.0); point.add(2.0);
		cgd.addPoint(point);
		
		cgd.setName("Smile");
		
		file = new File(Constants.dataPath + "//CustomGalaxies//SmileGalaxy.xml");
		fos = new FileOutputStream(file);
		osw = new OutputStreamWriter(fos);
		out = xstream.createObjectOutputStream(osw);		
		out.writeObject(cgd);
		out.close();
		
		
		//----------------------------------------------
		
		
		
		
		
		
		//----------------------------------------------
		//Continue...
		
		
		
		
		
		
//		FileInputStream fis = new FileInputStream(file);
//		InputStreamReader isw = new InputStreamReader(fis);
//		ObjectInputStream in = xstream.createObjectInputStream(isw);
//		
//		GalaxySize gs1 = (GalaxySize) in.readObject();
//		
//		for (Map.Entry<String, Integer> entry : gs1.getGalaxySizes().entrySet()) {
//			System.out.println(entry.getKey());
//			System.out.println(entry.getValue());
//		}
		
	}

}
